	function XmlDom(){
	var newXmlDom=document.implementation.createDocument("","",null);

	newXmlDom.parseError={
		valueOf: function() { return this.errorCode; },
		toString: function() { return this.errorCode.toString(); }
	};

	newXmlDom.__initError__();

	newXmlDom.addEventListener("load", function(){
		this.__checkForErrors__();
		this.__changeReadyState__(4);
	}, false);

	return newXmlDom;
}

function checkBrowser(){
	var browser=navigator.appName;

	if(browser == "Microsoft Internet Explorer"){
		alert("Dude, get a browser");
		return false;
	}else if(browser == "Netscape"){
		//alert("Coooll");
		Document.prototype.readyState=0;
		Document.prototype.onreadystatechange=null;

		Document.prototype.__changeReadyState__=function(iReadyState){
			this.readyState= iReadyState;

			if(typeof this.onreadystatechange == "function"){
				this.onreadystatechange();
			}
		};

		Document.prototype.__initError__=function(){
			this.parseError.errorCode=0;
			this.parseError.filepos=-1;
			this.parseError.line=-1;
			this.parseError.linepos=-1;
			this.parseError.reason=null;
			this.parseError.srcText=null;
			this.parseError.url=null;
		};

		Document.prototype.__checkForErrors__=function(){
			if(this.documentElement.tagName == "parsererror"){
				var reError=/>([\s\S]*?)Location:([\s\S]*?)Line Number (\d+), Column (\d+):<sourcetext>([\s\S]*?)(?:\-*\^)/;

				reError.test(this.xml);

				this.parseError.errorCode=-999999;
				this.parseError.reason=RegExp.$1;
				this.parseError.url=RegExp.$2;
				this.parseError.line=parseInt(RegExp.$3);
				this.parseError.linepos=parseInt(RegExp.$4);
				this.parseError.srcText=RegExp.$5;
			}
		};

		Document.prototype.loadXML=function(sXml){
			this.__initError__();

			this.__changeReadyState__(1);

			var newParser=new DOMParser();
			var newXmlDom=newParser.parseFromString(sXml, "text/xml");

			while(this.firstChild){
				this.removeChild(this.firstChild);
			}

			for(var i=0; i< newXmlDom.childNodes.length; i++){
				var newNode=this.importNode(newXmlDom.childNodes[i], true);
				this.appendChild(newNode);
			}

			this.__checkForErrors__();

			this.__changeReadyState__(4);
		};

		Document.prototype.__load__=Document.prototype.load;

		Document.prototype.load=function(sURL){
			this.__initError__();
			this.__changeReadyState__(1);
			this.__load__(sURL);
		};

		Node.prototype.__defineGetter__("xml", function(){
			var newSerializer=new XMLSerializer();
			return newSerializer.serializeToString(this, "text/xml");
		});

		Node.prototype.transformNode=function (newXslDom){
			var newProcessor=new XSLTProcessor();
			newProcessor.importStylesheet(newXslDom);

			var newResultDom=newProcessor.transformToDocument(this);
			var newResult=newResultDom.xml;

			//if(newResult.indexOf("<transformiix:result>") > -1){
			//alert("in");
			newResult=newResult.substring(newResult.indexOf(">")+1, newResult.lastIndexOf("<"));
			//}

			return newResult;
		}
	}
}


function showXml(){
	checkBrowser();
	var Xmldom=new XmlDom();
	var XslDom=new XmlDom();

	Xmldom.async=false;
	XslDom.async=false;

	Xmldom.load('documente/teste2/teste2.xml');
	XslDom.load('include/xsl/xmlDomObject.xslt');

	document.getElementById('helder').innerHTML=Xmldom.transformNode(XslDom);
	//return Xmldom.transformNode(XslDom);
}
